﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace rInvoice
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void AddUserControlInTabs(UserControl userControl)
        {
            // If not exist
            if (!mainTabControl.TabPages.ContainsKey(userControl.Name))
            {
                // Add it
                mainTabControl.TabPages.Add(userControl.Name, userControl.Name);

                TabPage tabPage = mainTabControl.TabPages[mainTabControl.TabPages.IndexOfKey(userControl.Name)];

                tabPage.ImageIndex = 2;
                tabPage.Controls.Add(userControl);
                userControl.Dock = DockStyle.Fill;
                mainTabControl.SelectedTab = tabPage;
                tabPage.Focus();
            }
            else
            {
                // Make it active
                TabPage tabPage = mainTabControl.TabPages[mainTabControl.TabPages.IndexOfKey(userControl.Name)];
                mainTabControl.SelectedTab = tabPage;
                tabPage.Focus();
            }

            Update();
        }

        private void usersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UsersAdministration usersPanel = new UsersAdministration();
            usersPanel.Name = "Users list";
            AddUserControlInTabs((UserControl)usersPanel);
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            Bank bankPanel = new Bank();
            bankPanel.Name = "Bank list";
            bankPanel.Dock = DockStyle.Fill;
            nomenclatoareTabControl.TabPages["banciTabPage"].Controls.Add(bankPanel);
            
            
            Constante constpanel = new Constante();
            constpanel.Name = "Constante";
            constpanel.Dock = DockStyle.Fill;
            nomenclatoareTabControl.TabPages["constanteTabPage"].Controls.Add(constpanel);


            Contracts contractsPanel = new Contracts();
            contractsPanel.Name = "Contracts list";
            contractsPanel.Dock = DockStyle.Fill;
            nomenclatoareTabControl.TabPages["contracteTabPage"].Controls.Add(contractsPanel);


            Products productPanel = new Products();
            productPanel.Name = "Product list";
            productPanel.Dock = DockStyle.Fill;
            nomenclatoareTabControl.TabPages["marfaTabPage"].Controls.Add(productPanel);


            Classifiers classifiersPanel = new Classifiers();
            classifiersPanel.Name = "Classifiers";
            classifiersPanel.Dock = DockStyle.Fill;
            nomenclatoareTabControl.TabPages["nomenclatoareAlteleTabPage"].Controls.Add(classifiersPanel);


            Company companyPanel = new Company();
            companyPanel.Name = "Company list";
            companyPanel.Dock = DockStyle.Fill;
            contactTabControl.TabPages["clientiTabPage"].Controls.Add(companyPanel);


            BalanceAccount balancePanel = new BalanceAccount();
            balancePanel.Name = "Balanta contului";
            balancePanel.Dock = DockStyle.Fill;
            rapoarteTabControl.TabPages["balantaContuluiTabPage"].Controls.Add(balancePanel);


            DocFisc docFiskPanel = new DocFisc();
            docFiskPanel.Name = "Facturi fiscale";
            docFiskPanel.Dock = DockStyle.Fill;
            documenteEmiseTabControl.TabPages["facturaFiscalaTabPage"].Controls.Add(docFiskPanel);



            DocFisc docFiskIntrariPanel = new DocFisc();
            docFiskIntrariPanel.Name = "Facturi fiscale";
            docFiskIntrariPanel.Dock = DockStyle.Fill;
            documenteIntrariTabControl.TabPages["intrariFacturaFiscalaTabPage"].Controls.Add(docFiskIntrariPanel);
            

            DocSimple facturiDeExpeditie = new DocSimple();
            facturiDeExpeditie.Name = "Facturi simple";
            facturiDeExpeditie.Dock = DockStyle.Fill;
            documenteEmiseTabControl.TabPages["facturaDeExpeditieTabPage"].Controls.Add(facturiDeExpeditie);


            DocSimple facturiDeIntrare = new DocSimple();
            facturiDeIntrare.Name = "Facturi simple";
            facturiDeIntrare.Dock = DockStyle.Fill;
            documenteIntrariTabControl.TabPages["intrariFacturadeExpeditieTabPage"].Controls.Add(facturiDeIntrare);


        }             
           



        //private void deIntrareToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    DocInput newPanel = new DocInput();
        //    newPanel.Name = "Facturi de intrari";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //private void deIncasareToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    InvoiceInput newPanel = new InvoiceInput();
        //    newPanel.Name = "Ordine de incasare";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //private void dePlataToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    InvoiceOutput newPanel = new InvoiceOutput();
        //    newPanel.Name = "Ordine de plata";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //public void AddCompanyAccountInputPanelWithParameters(bool selectOne, int companyAccountID)
        //{
        //    CompanyAccount newPanel = new CompanyAccount(selectOne, companyAccountID);
        //    newPanel.Name = "Comany Accounts";

        //    if (mainTabControl.TabPages.ContainsKey(newPanel.Name))
        //    {
        //        TabPage tabpage = mainTabControl.TabPages[newPanel.Name];

        //        mainTabControl.TabPages.Remove(tabpage);
        //    }

        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //private void trezorialToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    InvoiceTax newPanel = new InvoiceTax();
        //    newPanel.Name = "Ordine trezorial";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //private void evidentaIntrariToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    QueryInput newPanel = new QueryInput();
        //    newPanel.Name = "Evidenta intrari";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //private void evidentaIesiriToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    QueryOutput newPanel = new QueryOutput();
        //    newPanel.Name = "Evidenta iesirilor";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

        //private void evidentaAchitarilorToolStripMenuItem_Click(object sender, EventArgs e)
        //{
        //    QueryPay newPanel = new QueryPay();
        //    newPanel.Name = "Evidenta achitarilor";
        //    AddUserControlInTabs((UserControl)newPanel);
        //}

       
       

    }
}
